﻿using System;
using Character;
using UnityEngine;

// Token: 0x020001DC RID: 476
public class CoordinateCapture : MonoBehaviour
{
	// Token: 0x06000CB0 RID: 3248 RVA: 0x0004C3C4 File Offset: 0x0004A5C4
	private void Start()
	{
		this.capCamera.enabled = false;
	}

	// Token: 0x06000CB1 RID: 3249 RVA: 0x0004C3D4 File Offset: 0x0004A5D4
	private void OnDestroy()
	{
	}

	// Token: 0x06000CB2 RID: 3250 RVA: 0x0004C3D8 File Offset: 0x0004A5D8
	public Texture2D Capture()
	{
		this.capCamera.enabled = true;
		int num = this.saveWidth * this.superSize;
		int num2 = this.saveHeight * this.superSize;
		RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 24);
		this.capCamera.targetTexture = temporary;
		this.capCamera.Render();
		RenderTexture.active = temporary;
		Texture2D texture2D = new Texture2D(num, num2, TextureFormat.RGB24, false);
		texture2D.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
		texture2D.Apply();
		TextureScale.Bilinear(texture2D, this.saveWidth, this.saveHeight);
		this.capCamera.targetTexture = null;
		RenderTexture.ReleaseTemporary(temporary);
		this.capCamera.enabled = false;
		return texture2D;
	}

	// Token: 0x06000CB3 RID: 3251 RVA: 0x0004C490 File Offset: 0x0004A690
	public void Save(string file)
	{
		this.mannequin.FromHuman(this.human);
		this.human.SaveCoordinate(file, this.Capture());
		this.mannequin.Strip();
	}

	// Token: 0x06000CB4 RID: 3252 RVA: 0x0004C4C0 File Offset: 0x0004A6C0
	public void SetHuman(Human human)
	{
		this.human = human;
		if (human.sex == SEX.MALE)
		{
			this.capCamera.transform.localPosition = new Vector3(0f, 0.92f, 4.4f);
			this.capCamera.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			this.mannequin = this.mannequin_M;
			this.mannequin_M.gameObject.SetActive(true);
			this.mannequin_F.gameObject.SetActive(false);
		}
		else
		{
			this.capCamera.transform.localPosition = new Vector3(0f, 0.87f, 4.2999997f);
			this.capCamera.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
			this.mannequin = this.mannequin_F;
			this.mannequin_M.gameObject.SetActive(false);
			this.mannequin_F.gameObject.SetActive(true);
		}
	}

	// Token: 0x04000CDF RID: 3295
	[SerializeField]
	private Camera capCamera;

	// Token: 0x04000CE0 RID: 3296
	[SerializeField]
	private int superSize = 2;

	// Token: 0x04000CE1 RID: 3297
	[SerializeField]
	private int saveWidth = 252;

	// Token: 0x04000CE2 RID: 3298
	[SerializeField]
	private int saveHeight = 352;

	// Token: 0x04000CE3 RID: 3299
	[SerializeField]
	private Mannequin mannequin_F;

	// Token: 0x04000CE4 RID: 3300
	[SerializeField]
	private Mannequin mannequin_M;

	// Token: 0x04000CE5 RID: 3301
	private Mannequin mannequin;

	// Token: 0x04000CE6 RID: 3302
	private Human human;
}
